import React,{Component} from 'react'
import {Link,browserHistory} from 'react-router'
import * as pub from '../config/public';
class Entrance extends Component {
	constructor(args) {
		super();
	}
	componentWillMount() {
		if (localStorage.getItem('user') === null) {
			pub.jumpHistory.push('/Login');
			return;
		}
		let userType = pub.user.userType;
		if (userType === '学员') {
			localStorage.setItem("now_userType", userType);
			pub.jumpHistory.push('/');
			return;
		}
	}

	render(){
		return(
		<div className="login-bg login-bg-1">
			<div className="login-box">
				<div className="login-logo"><div className="logo"></div><img className="login-logoImg" alt="test" src={require('../style/images/login-logo.png')} width="200" style={{verticalAlign: 'middle'}}/></div>
	
				 <div className="login-in-btn">
					{pub.user.job.map((item, index) => {
						return(
							   <div key={index}>
							       {(()=>{
							       	switch(item){
							       		case '学员':return <Link to='/' onClick={()=>{localStorage.setItem("now_userType", '学员')}} ><i className="icon-zn" ></i>智能学习平台</Link>;
							       		case '讲师':return <Link to='/CourseManage' onClick={()=>{localStorage.setItem("now_userType", '讲师')}}><i className="icon-kc" ></i>课程管理平台</Link>;
							       		case '管理员':return <Link to='/admin' onClick={()=>{localStorage.setItem("now_userType", '管理员')}}><i className="icon-kc" ></i>运营后台管理</Link>;
							       		default:break;
							       	}
							       	})()}
							   </div>
							)
					})}
					 </div>
				
			</div>
		</div>
			)
	}
}
export default Entrance;